home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / utility3 / vbcards.zip / VBCARDS.DOC < prev   
Text File  |  1991-09-25  |  9KB  |  212 lines

  1. ============================================================================
  2.                                
  3.                         VBCARDS.DLL - Version 1.01P
  4.                                                            
  5.                T h e   G r i n n i n g   J a c k   D e c k
  6.  
  7.                         Written by Richard R. Sands
  8.                               CIS 70274,103
  9.  
  10. ============================================================================
  11.  
  12. The VBCARDS.DLL is a library of routines that allows card-game
  13. applications to share common bitmap resources.  It also provides some
  14. basic support routines.
  15.  
  16. Personally, I'm tired of getting card games, each that contain a copy of
  17. their own bitmaps for the cards.  Hopefully, this can form a basis for
  18. writing card games that can share the images thus saving diskspace and
  19. memory.
  20.  
  21. This library contains the basic card values Ace through King, a Joker, and
  22. seven card back styles.  It also includes a couple of misc. cards used to
  23. indicate (non-)empty decks (a green X and a green O card).
  24.  
  25. The compiled DLL is released to the Public Domain.  Turbo Pascal for
  26. Windows Source code is available from me for a nominal $5.00.  You may not
  27. distribute the DLL source code.
  28.  
  29. I am completely open to suggestions for improvement, bugs, and, of course, 
  30. critisisms (who me?).  Send them to this forum or use email.
  31.  
  32. Although the DLL is public domain, I *sure* would like to see some of the 
  33. games that is created using this DLL!
  34.  
  35.  
  36. ============================================================================
  37. IMPLEMENTATION NOTES
  38. ============================================================================
  39.   1. Note that the DLL, when a card image routine is called, will place the 
  40.      card into the clipboard.  So don't try to keep something in the Clip-
  41.      board while playing a card game.
  42.  
  43.   2. Set the BorderStyle property of each card to 0 - No Border
  44.  
  45.   3. Given an array:
  46.                              Option Base 1
  47.                              Global Deck(52) As Integer
  48.      then a these will work:
  49.  
  50.      Sub InitDeck ()
  51.          For I = 1 to 52
  52.             Deck(i) = i
  53.          Next I
  54.      End Sub
  55.  
  56.      Sub ShuffleDeck ()
  57.          For I = 1 to 10
  58.            For J = 1 to 52
  59.                K = Int( 1 + (52 * Rnd))
  60.                Temp = Deck(j)
  61.                Deck(j) = Deck(k)
  62.                Deck(k) = Temp
  63.            Next 
  64.          Next
  65.      End Sub
  66.  
  67. ============================================================================
  68. THE ROUTINE DOCUMENTATION
  69. ============================================================================
  70. You must declare the following routines in a module to access these subs
  71. and functions:
  72.  
  73. Declare Function CardVersion Lib "VBCards.dll" () As Integer
  74.  
  75. Declare Sub GetCard Lib "VBCards.dll" (ByVal Card As Integer)
  76. Declare Sub GetCardBack Lib "VBCards.dll" (ByVal C As Integer)
  77. Declare Sub GetCardMisc Lib "VBCards.dll" (ByVal C As Integer)
  78.  
  79. Declare Function SuitOf Lib "VBCards.dll" (ByVal C As Integer) As Integer
  80. Declare Function SameSuit Lib "VBCards.dll" (ByVal c1 As Integer, ByVal c2 As Integer) As Integer
  81. Declare Function IsCardRed Lib "VBCards.dll" (ByVal C As Integer) As Integer
  82. Declare Function IsCardBlack Lib "VBCards.dll" (ByVal C As Integer) As Integer
  83. Declare Function IsCardSameColor Lib "VBCards.dll" (ByVal C1 as Integer, ByVal C2 As Integer) As Integer
  84.  
  85. Declare Function CardValue Lib "VBCards.dll" (ByVal C As Integer) As Integer
  86. Declare Function SameCardValue Lib "VBCards.dll" (ByVal c1 As Integer, ByVal c2 As Integer) As Integer
  87.  
  88.  
  89. You should declare in the GLOBALS section:
  90.  
  91. Global Const NumCards  = 52 'Or 53 if you want to include the Joker
  92. Global Const CardWidth = 71
  93. Global Const CardHeight= 96
  94.  
  95. Global Const Spades = 1
  96. Global Const Hearts = 2
  97. Global Const Clubs  = 3
  98. Global Const Diamonds = 4
  99.  
  100.  
  101. ============================================================================
  102. VERSION ROUTINE
  103. ============================================================================
  104. Function CardVersion () As Integer
  105.  
  106.   This returns the version number. Eg. Version 1.01 is returned as 101.
  107.   This function should be called before any other routines are executed.
  108.  
  109.  
  110. ============================================================================
  111. BASIC CARD BITMAP ROUTINES
  112. ============================================================================
  113. Sub GetCard (ByVal Card As Integer)
  114.  
  115.   This routine will copy the card specified to the clipboard.  You can then
  116.   assign the clipboard contents (bitmap=2) to a control.Picture.
  117.  
  118.   Values 1..13 are Spades.  11=Jack, 12=Queen, 13=King.  Values 14..26 are
  119.   Hearts, 27..39 are Clubs, and, 40-52 are Diamonds.  The Joker is 53.
  120.  
  121.   Example:
  122.            GetCard(13)'King of Spades
  123.            Picture1(i).Picture = ClipBoard.GetCard(2)' 2=Bitmap
  124.  
  125.  
  126. ----------------------------------------------------------------------------
  127. Sub GetCardBack (ByVal Card As Integer)
  128.  
  129.   This routine will copy the card back specified to the clipboard.  You can
  130.   then assign the clipboard contents (bitmap=2) to a control.Picture.
  131.  
  132.   As supplied, valid values are 1..7
  133.  
  134. ----------------------------------------------------------------------------
  135. Sub GetCardMisc (ByVal Card As Integer)
  136.  
  137.   This routine will copy the misc. card specified to the clipboard.  You can
  138.   then assign the clipboard contents (bitmap=2) to a control.Picture.
  139.  
  140.   As supplied, valid values are 1 and 2.  1 returns a green card with a big
  141.   red X on it, and 2 returns a green card with a large O on it.
  142.  
  143.  
  144. ============================================================================
  145. CARD SUIT COMPARISON ROUTINES
  146. ============================================================================
  147. Function SuitOf (ByVal C As Integer) As Integer
  148.  
  149.   This routine returns the suit of the card as an integer.  It returns 0 if
  150.   the card is not in the range of 1..52.
  151.  
  152.   Values of the suits are:
  153.                           1  Spades
  154.                           2  Hearts
  155.                           3  Clubs
  156.                           4  Diamonds
  157.  
  158. ----------------------------------------------------------------------------
  159. Function SameSuit (ByVal c1 As Integer, ByVal c2 As Integer) As Integer
  160.  
  161.   This returns -1 (true) if cards C1 and C2 are the same suit.  Returns zero
  162.   if the card is not valid.
  163.  
  164. ----------------------------------------------------------------------------
  165. Function IsCardRed (ByVal C As Integer) As Integer
  166.  
  167.   This returns -1 (true) if the card C is a Heart or Diamond.  Returns zero
  168.   if the card is not valid.
  169.  
  170. ----------------------------------------------------------------------------
  171. Function IsCardBlack (ByVal C As Integer) As Integer
  172.  
  173.   This returns -1 (true) if the card C is a Spade or Club.  Returns zero
  174.   if the card is not valid.
  175.  
  176. ----------------------------------------------------------------------------
  177. Function IsCardSameColor (ByVal C1 as Integer, ByVal C2 As Integer) As Integer
  178.  
  179.   This returns -1 (true) if the card C1 is a the same color as C2.  Returns
  180.   zero if the card is not valid.
  181.  
  182.  
  183. ============================================================================
  184. CARD VALUE COMPARISON ROUTINES
  185. ============================================================================
  186. Function CardValue (ByVal C As Integer) As Integer
  187.  
  188.   This returns the value of a card.  All values are in the range of 1..13.
  189.   For example, card 14 is the Ace of Hearts.  Card 39 is the King of Clubs.
  190.   Returns zero if the card is not valid.
  191.  
  192. ----------------------------------------------------------------------------
  193. Function SameCardValue (ByVal c1 As Integer, ByVal c2 As Integer) As Integer
  194.  
  195.   This returns the -1 (true) if the value of C1 is the same as C2
  196.   For example, card 13 has the same value as 26.  Returns zero if the card
  197.   is not valid.
  198.  
  199.  
  200. ============================================================================
  201. ADDING NEW BACK VALUES
  202. ============================================================================
  203. If you have the Whitewater Resource Toolkit (WRT.EXE) or Resource Workshop
  204. (RW.EXE) then you can edit the VBCards.dll to add new card backs.  The
  205. Card Back Resources are valued at 60 through 89 of which I have provided
  206. 60 through 66 (7 card backs).
  207.  
  208. The bitmaps for the images are 71 pixels wide and 96 pixels high.
  209.  
  210. Optionally, the backs could be released as .BMP files so users can add the
  211. .BMP files themselves.
  212.